//
//  SubmitOrderVC.m
//  LoveTrail
//
//  Created by giantumbrella on 15/6/10.
//  Copyright (c) 2015年 赵娟. All rights reserved.
//

#import "SubmitOrderVC.h"
#import "CommonMacro.h"
#import "allAddressVC.h"
#import "ButtomSubmitView.h"
#import "EditAddreSOView.h"
#import "SurePayVC.h"

@interface SubmitOrderVC ()<submitOrderButtonDelegate,changeAddressButtonDelegate>
@property (nonatomic,strong) ButtomSubmitView *buttomSubmitView;
@property (nonatomic,strong) EditAddreSOView *editAddreView;
@property (nonatomic,strong) UILabel *titleLabel;
@property (nonatomic,strong) SurePayVC *surePayVC;
@end

@implementation SubmitOrderVC

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.view setBackgroundColor:[UIColor whiteColor]];
    
    self.title = @"提交订单";
    self.navigationItem.rightBarButtonItem = nil;
    
    //创建tableView
    [self createView];
}

#pragma mark 底部的实付款 提交订单按钮
- (void)createView
{
    
    //1.创建tableView
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 70, SCREEN_WIDTH, SCREEN_HEIGHT*0.3)];
//    self.tableView.backgroundColor = [UIColor grayColor];
    self.tableView.dataSource = self;
    self.tableView.delegate = self;
    self.tableView.showsVerticalScrollIndicator = NO;
    [self.view addSubview:self.tableView];
    
    //0.订单详情文字
    self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, self.tableView.frame.origin.y, self.tableView.frame.size.width*0.4, 20)];
    self.titleLabel.text = @"订单详情";
//    self.titleLabel.backgroundColor = [UIColor redColor];
    self.titleLabel.font = [UIFont boldSystemFontOfSize:20];
    self.titleLabel.textColor = UIColorWithRGBA(138, 135, 135, 1);
    [self.view addSubview:self.titleLabel];

    //2.默认收货地址
    self.buttomSubmitView = [[ButtomSubmitView alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT-50, self.tableView.frame.size.width, 50)];
     self.buttomSubmitView.submitDelegate = self;
    [self.view addSubview:self.buttomSubmitView];
   
    //3.添加底部视图
    self.editAddreView = [[EditAddreSOView alloc] initWithFrame:CGRectMake(0, self.tableView.frame.size.height+self.tableView.frame.origin.y, SCREEN_WIDTH, SCREEN_HEIGHT*0.4)];
       self.editAddreView.delegate = self;
    [self.view addSubview:self.editAddreView];
 
}

#pragma mark tableViewDataSource

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
   static NSString *ID = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell==nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];
    }
    
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 80;
}
#pragma mark 改变收货地址
- (void)changeAddressButton
{
    allAddressVC *allAddress = [[allAddressVC alloc] init];
    UINavigationController *allAddreNav = [[UINavigationController alloc] initWithRootViewController:allAddress];
    [self presentViewController:allAddreNav animated:YES completion:nil];
}

#pragma mark  提交菜单
- (void)submitOrderButton
{
    self.surePayVC = [[SurePayVC alloc] init];
    UINavigationController *surePayVC = [[UINavigationController alloc] initWithRootViewController:self.surePayVC];
    self.surePayVC.pathTitle = @"提交订单";
    [self presentViewController:surePayVC animated:YES completion:nil];
}
@end
